package com.ruoyi.safe.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.safe.domain.TSpecialZone;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 专区Mapper接口
 *
 * @author zmk
 * @date 2025-03-24
 */
@Mapper
public interface TSpecialZoneMapper extends BaseMapper<TSpecialZone> {
    /**
     * 查询专区
     *
     * @param zoneId 专区主键
     * @return 专区
     */
    public TSpecialZone selectTSpecialZoneByZoneId(Long zoneId);

    /**
     * 查询专区列表
     *
     * @param tSpecialZone 专区
     * @return 专区集合
     */
    public List<TSpecialZone> selectTSpecialZoneList(TSpecialZone tSpecialZone);

    /**
     * 新增专区
     *
     * @param tSpecialZone 专区
     * @return 结果
     */
    public int insertTSpecialZone(TSpecialZone tSpecialZone);

    /**
     * 修改专区
     *
     * @param tSpecialZone 专区
     * @return 结果
     */
    public int updateTSpecialZone(TSpecialZone tSpecialZone);

    /**
     * 删除专区
     *
     * @param zoneId 专区主键
     * @return 结果
     */
    public int deleteTSpecialZoneByZoneId(Long zoneId);

    /**
     * 批量删除专区
     *
     * @param zoneIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTSpecialZoneByZoneIds(Long[] zoneIds);

    @Select("select zone_id, del_flag, create_by, create_time, update_by, update_time, title, parent_id,heat_deg," +
            " evaluation_count, home_background, avatar, fans_count " +
            "from t_special_zone sz where del_flag = 0 and EXISTS(select zone_id from t_user_zone uz where uz.zone_id = sz.zone_id and user_id = #{userId})")
    List<TSpecialZone> getMyZone(Long userId);

}
